# from https://cmake.org/Wiki/CMake:How_To_Find_Libraries

find_package(PkgConfig REQUIRED)
if(PKG_CONFIG_FOUND)
  pkg_search_module(ParMetis REQUIRED IMPORTED_TARGET parmetis)

  include (FindPackageHandleStandardArgs)
  find_package_handle_standard_args (ParMetis
    REQUIRED_VARS ParMetis_FOUND ParMetis_INCLUDE_DIRS ParMetis_LIBRARIES
    VERSION_VAR ParMetis_VERSION
    )            

  if(NOT TARGET ParMetis::ParMetis)
    add_library(ParMetis::ParMetis ALIAS PkgConfig::ParMetis)
  endif()

  mark_as_advanced(ParMetis_INCLUDE_DIRS ParMetis_LIBRARIES ParMetis_VERSION_MAJOR ParMetis_VERSION_MINOR ParMetis_VERSION_PATCH VERSION_VAR ParMetis_VERSION)
endif()